package com.cavy.platform.server.controller;

import com.cavy.platform.server.ResultInfo;
import com.cavy.platform.server.dto.AgentDeleteDto;
import com.cavy.platform.server.dto.AgentRegisterDto;
import com.cavy.platform.server.dto.AgentStatusDto;
import com.cavy.platform.server.service.AgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 客户端控制器
 */
@RestController
@RequestMapping("agent")
public class AgentController {

    @Autowired
    private AgentService service;

    @PostMapping("register")
    public ResultInfo register(@RequestBody @Valid AgentRegisterDto dto) {
        service.register(dto);
        return ResultInfo.newSuccess();
    }

    @PostMapping("status")
    public ResultInfo status(@RequestBody @Valid AgentStatusDto dto) {
        service.status(dto);
        return ResultInfo.newSuccess();
    }

    @PostMapping("delete")
    public ResultInfo delete(@RequestBody @Valid AgentDeleteDto dto) {
        service.delete(dto);
        return ResultInfo.newSuccess();
    }
}
